<?php
/*
Plugin Name: Collapsible Links Widget
Plugin URI: http://www.silkrt.com
Description: Allows for widget-based collapsible Links, based on the "List Expander" written by Alan Grakalic at cssglobe.com. and Collapsible Categories Widget by Leo Jackson (email: leo.jackson@gmail.com)
Version: 0.1
Author: marc lin
Author URI: http://www.silkrt.com
*/


function col_links_init() {

function col_links_css() {
	$blog_url = get_bloginfo('url');
	echo '<link href="'.$blog_url.'/wp-content/plugins/col_cats/col_cats.css" rel="stylesheet" type="text/css" media="screen" />';
	echo '<script type="text/javascript" src="'.$blog_url.'/wp-content/plugins/col_cats/col_cats.js"></script>';
}

function col_links_widget($args) {
	extract($args);
	$options = get_option('col_links_widget');
	$c = $options['count'] ? '1' : '0';
	$title = empty($options['title']) ? __('Links') : $options['title'];
	echo $before_widget;
	echo $before_title.$title.$after_title;
?>
<ul class="col_cats">
<?php wp_list_bookmarks('title_li=&orderby=name'); ?>
</ul>
<?php
	echo $after_widget;
}

function col_links_widget_control() {
	$options = $newoptions = get_option('col_links_widget');
	if ( $_POST['Links-submit'] ) {
		$newoptions['title'] = strip_tags(stripslashes($_POST['Links-title']));
	}
	if ( $options != $newoptions ) {
		$options = $newoptions;
		update_option('col_links_widget', $options);
	}
	$title = wp_specialchars($options['title']);
?>
			<p><label for="Links-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="Links-title" name="Links-title" type="text" value="<?php echo $title; ?>" /></label></p>
		
			<input type="hidden" id="Links-submit" name="Links-submit" value="1" />
<?php
}

add_action ('wp_head','col_links_css');

register_sidebar_widget('Collapsible Links','col_links_widget');
register_widget_control('Collapsible Links','col_links_widget_control');

}

add_action ('plugins_loaded','col_links_init');

?>
